#pragma once
#include "stdafx.h"
#include "ui_parameter_editor.h"
#include "units.h"

class Editor : public QDialog
{
	Q_OBJECT
private:
	Ui::editorDialog ui;
	vector<QTableWidgetItem *> x, y;
	
	void checkFirstRow();
	QCustomPlot *plot;
	
public:
	Editor(QWidget* pwgt = 0);	
	~Editor();
	QString getData();
	void setData(const QString &name, const QString &text);
	
private slots:
	void on_btnAccept_clicked();
	void on_btnReject_clicked();
	void on_btnLoad_clicked();
	void on_btnAddRow_clicked();
	void on_btnRemoveRow_clicked();
	void on_btnRefresh_clicked();
	void on_bClear_clicked();
protected slots:
	void update_plot();
	void update_plot_sl(int index){ update_plot(); }
};

class LineEditDelegate : public QItemDelegate{
	Q_OBJECT
public:
	LineEditDelegate(QObject* parent = 0);
	QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
	void setEditorData(QWidget* editor, const QModelIndex& index) const;
	void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
	void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
};